#ifndef CUDA_DEFS_H_
#define CUDA_DEFS_H_

#include "cuda_error_check.h"

#define GPUMALLOC(D_POINTER, SIZE) CUDA_SAFE_CALL(cudaMalloc(D_POINTER, SIZE))
#define CPUMALLOC(H_POINTER, SIZE) CUDA_SAFE_CALL(cudaMallocHost(H_POINTER, SIZE))

#define CPUFREE(H_POINTER) \
	do { \
	if(H_POINTER) CUDA_SAFE_CALL(cudaFreeHost(H_POINTER)); \
	H_POINTER = NULL; \
	} while(0)

#define GPUFREE(D_POINTER) \
	do { \
	if(D_POINTER) CUDA_SAFE_CALL(cudaFree(D_POINTER)); \
	D_POINTER = NULL; \
	} while(0)

#define TOGPU(D_POINTER, H_POINTER, SIZE) CUDA_SAFE_CALL(cudaMemcpy(D_POINTER, H_POINTER, SIZE, cudaMemcpyHostToDevice))
#define FROMGPU(H_POINTER, D_POINTER, SIZE) CUDA_SAFE_CALL(cudaMemcpy(H_POINTER, D_POINTER, SIZE, cudaMemcpyDeviceToHost))
#define FROMGPU_ASYNC(H_POINTER, D_POINTER, SIZE) CUDA_SAFE_CALL(cudaMemcpyAsync(H_POINTER, D_POINTER, SIZE, cudaMemcpyDeviceToHost))
#define GPUTOGPU(D_TO, D_FROM, SIZE) CUDA_SAFE_CALL(cudaMemcpy(D_TO, D_FROM, SIZE, cudaMemcpyDeviceToDevice))
#define TOGPU_CONSTANT(D_POINTER, H_POINTER, SIZE) CUDA_SAFE_CALL(cudaMemcpyToSymbol(D_POINTER, H_POINTER, SIZE, 0, cudaMemcpyHostToDevice))
#define GPUMEMSET(D_TO, VALUE, SIZE) CUDA_SAFE_CALL(cudaMemset(D_TO, VALUE, SIZE))

#define WRAP_SIZE 32
#define MAX_SAMPLES 307200
#define MAX_INTERVAL 2048
#define MAX_FRONT (NUM_THREADS * NUM_BLOCKS)
#define RANDOM_SEED 0
#define NUM_THREADS 256
#define NUM_BLOCKS 48

// Needed to be changed for different dimensions
#define DIMENSIONS 10
//#define USE_GRID_BASED_NEIGHBOR_SEARCH

#endif
